﻿@using System.Web.Mvc

@helper ProjectList()
{
    var urlBrowser = new UrlHelper(Request.RequestContext);

    <script type="text/html" id="projectlist-template">
        <div class="col-md-4">
            <div class="project-list-item">
                <a href="#" data-bind="click: Main.Page.ChangePage.bind($data,'@urlBrowser.Action("Main", "Project")')">
                    @ProjectFields()
                </a>
            </div>
        </div>
    </script>
}

@helper PendingProjectList()
{
    var urlBrowser = new UrlHelper(Request.RequestContext);

    <script type="text/html" id="pending-projectlist-template">
        <div class="col-md-4">
            <div class="project-list-item">
                <div class="row action-bar">
                    <button class="btn btn-default btn-sm" data-bind="click: $root.SetToOnRevision.bind($data)"><span>A revisiòn</span></button>
                </div>

                <a href="#" data-bind="click: Main.Page.ChangePage.bind($data,'@urlBrowser.Action("Main", "Project")')">
                    @ProjectFields()
                </a>
            </div>
        </div>
    </script>
}

@helper OnRevisionProjectList()
{
    var urlBrowser = new UrlHelper(Request.RequestContext);

    <script type="text/html" id="onrevision-projectlist-template">
        <div class="col-md-4">
            <div class="project-list-item">
                <div class="row action-bar">
                    <button class="btn btn-default btn-sm" data-bind="click: $root.SelectItem.bind($data,'Update')"><span>Editar</span></button>
                    <button class="btn btn-default btn-sm" data-bind="click: $root.BackToPending.bind($data)"><span>Volver a pendiente</span></button>
                    <button class="btn btn-default btn-sm" data-bind="click: $root.SetToApproved.bind($data)"><span>Aprobado</span></button>
                </div>

                <a href="#" data-bind="click: Main.Page.ChangePage.bind($data,'@urlBrowser.Action("Main", "Project")')">
                    @ProjectFields()
                </a>
            </div>
        </div>
    </script>
}

@helper ApprovedProjectList()
{
    var urlBrowser = new UrlHelper(Request.RequestContext);

    <script type="text/html" id="approved-projectlist-template">
        <div class="col-md-4">
            <div class="project-list-item">
                <div class="row action-bar">
                    <button class="btn btn-default btn-sm" data-bind="click: $root.BackToOnRevision.bind($data)"><span>Volver a revision</span></button>
                </div>

                <a href="#" data-bind="click: Main.Page.ChangePage.bind($data,'@urlBrowser.Action("Main", "Project")')">
                    @ProjectFields()
                </a>
            </div>
        </div>
    </script>
}

@helper ProjectFields()
{
    <div align="center">
        <img data-bind="attr: { src: Image }" width="200" height="200" />
    </div>
    <div>
        <h2 data-bind="text: Title"></h2>
    </div>
    <div>
        <span data-bind="text: Description"></span>
    </div>
    <div>
        <h2>Empieza:<span data-bind="text: moment(StartDate()).format('DD-MM-YYYY')"></span></h2>
    </div>
    <div>
        <h2>Finaliza:<span data-bind="text: moment(DeadLine()).format('DD-MM-YYYY')"></span></h2>
    </div>
    <div>
        <h2>Costo:<span data-bind="text: '$' + Cost()"></span></h2>
    </div>
}